<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>await</title>
</head>
<body>
    <script>
        async function main(){
            let P = new Promise((resolve, reject) => {
                // resolve("ok");
                reject("error");
            })
            //1.右侧为promise对象
            // let res = await P;
            // console.log(res);
            //2.右侧为其他值
            // let res = await 666;
            // console.log(res);
            /*3.右侧为失败的promise对象*/
            try{
                let res = await P;
                console.log(res);
            }catch(e){
                console.log(e);
            }
        }
        main();
    </script>
</body>
</html>